package com.zx.kitchen.index.common.mvp.presenter;

import android.content.Context;

import com.zx.kitchen.index.common.entity.PrintOrderBean;
import com.zx.kitchen.index.common.mvp.OnResultListener;
import com.zx.kitchen.index.common.mvp.model.PrintDetailModelImpl;
import com.zx.kitchen.index.common.mvp.view.PrintDetailView;

/**
 * Created by Administrator on 2017/3/8.
 */

public class PrintDetailPresenter implements OnResultListener {
    private PrintDetailModelImpl printDetailModel;
    private PrintDetailView printDetailView;
    private Context context;

    public PrintDetailPresenter(Context context, PrintDetailView printDetailView) {
        this.context = context;
        this.printDetailView = printDetailView;
        printDetailModel = new PrintDetailModelImpl();
    }

    public void getFromNet(String id, boolean type) {
        printDetailModel.getFromNet(1, context, Integer.parseInt(id),type, this, null);
    }


    @Override
    public void onSuccess(int requestCode, String str) {
        PrintOrderBean printOrderBean = printDetailModel.asyncJson(str);
        printDetailView.onSuccess(printOrderBean);
    }


    @Override
    public void onFailure(int requestCode, String str) {
        printDetailView.onFail(str);
    }
}
